<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div id="app">
        <h1>搜索器</h1>
        <input type="text" name="search" v-model.trim.lazy="movie"><br>
        <ul>
            <li v-for="item in newTv" :key="item.id">电视剧名称：{{item.name}} <br> 主演人员：{{item.person}}</li>
        </ul>
    </div>
    <script>
        const vm = new Vue({
            el: '#app',
            data() {
                return {
                    Tv:[
                        {id:'001',name:'沉香如屑',person:'杨紫，成毅'},
                        {id:'002',name:'少年派2',person:'郭俊辰，赵今麦'},
                        {id:'003',name:'琉璃',person:'袁冰妍，成毅'},
                        {id:'004',name:'楚乔传',person:'赵丽颖，林更新'},
                    ],
                    movie:'',
                    newTV:[]
                }
            },
            watch:{
                movie:{
                    immediate:true,
                    handler(newValue){
                        console.log(newValue);
                        this.newTv=this.Tv.filter(item=>{
                           return item.name.includes(this.movie) || item.person.includes(this.movie)
                        
                        })
                    }
                }
            }
        })
    </script>
</body>

</html>